<?php


 // START GET DATA THEO GET  METHOD-------------

	$order="id desc";
	$url="";
	if(isset($_GET['ext'])){
		
		switch($_GET['ext']){
			case 'views':
			case 'likes':
			case 'comments':
			$order= $_GET['ext']." ".$_GET['sort'];
			break;
			case "date":
			$order= "id ".$_GET['sort'];
			break;
			case "thumbs":
			$order= "kd_".trim($_GET['sort'])." desc";
			break;
		}
	$url="index.php?ext=".$_GET['ext']."&sort=".$_GET['sort']."&page=";
	}
	
	
	$cache=new Cache;
	$sql ="select id,cat_id,post_id,username,id_album ,is_image,is_video,is_text,kd_up,kd_down,views,likes,comments from index_post order by ".$order;
	$sql2="select id from index_post";
	
	$pager = new Pagination($sql,LOAD_ITEMS,4,$url,5,"post");
	$pager->setDebug(false);
	$data[info] = $pager->paginate($cache,$sql2);
	$data[nav]	= $pager->renderFullNav();
	$data['page']=$pager->get_num_page();
	
	//GÁN SESSION ĐỂ FOLLOW
	$_SESSION['load']['query']=$sql;
	$_SESSION['load']['tpage']=$data['page'];
	// END OF GET DATA THEO GET MOTHOD
	if($data['page'] < $_GET['page']){
		$data[info]='';
	}	// NEU GET PAGE = 1 HOAC GET PAGE % 5 ==0 , THI RENDER LAI DATA
	if(!isset($_GET['page']) || $_GET['page']==1 || $_GET['page']% LOAD_TIME ==0){
			
			
			
			$data1[title]=web_title(HEAD,'home');

			loadview('template/header',$data1);
			if($_SESSION['mobile']!=0){
					loadview("news/list_news",$data);
			}else
			if($_SESSION['list_news_list'] == 1){
				loadview("news/list_news_list",$data);
			}else{
				loadview("news/list_news_grid",$data);
			}
			
		//loadview('template/right');
	}else{
		exit();
	}